import {report} from './request.js';
import '@babel/polyfill';
import '../css/index.css';
import '../css/information.css';
import '../css/return.css';
let box_main = document.querySelector(".box_main");
let _day = document.querySelector(".box_main>span");
let _ewmBox = document.querySelector(".ewmBox>img")
let cc_time = sessionStorage.getItem("cc_time"); 

// 返回按钮
let returnbtn = document.querySelector(".return");
returnbtn.addEventListener("click",function () {
    if (sessionStorage.getItem("token")) {
        window.location.href = "./index.html";
    }else{
        alert("error!!!")
    }
})

let data = {
    "name": `${sessionStorage.getItem("_name")}`,
    "phone": `${sessionStorage.getItem("phone")}`,
}
// 2.0
report(data).then(res => {
    box_main.innerHTML = 
    `
    <p>姓名:${sessionStorage.getItem("_name")}</p>
    <span>场次: ${res.result[res.result.length-1].day_time} <br/> ${cc_time}</span>
    <div class="ewmBox">
        <img src="${sessionStorage.getItem("img")}" alt="">
    </div>
    `
}).catch(err => {
    console.log(err);
});
// 1.0
// ajax("http://newshopapi.0melon0.cn/api/f_user/report", {
//         "name": `${sessionStorage.getItem("_name")}`,
//         "phone": `${sessionStorage.getItem("_phone")}`,
//     }, "POST").then(res => {
//         box_main.innerHTML = 
//         `
//         <p>姓名:${sessionStorage.getItem("_name")}</p>
//         <span>场次: ${res.result[res.result.length-1].day_time} <br/> ${cc_time}</span>
//         <div class="ewmBox">
//             <img src="${sessionStorage.getItem("img")}" alt="">
//         </div>
//         `
//     }).catch(err => {
//         console.log(err);
//     });